#include "Card.h"
#include <assert.h>

Card::Card()
    :card(0)
{}

Card::Card(int num)
    :card(num)
{
    this->setData(card);
}
    
int Card::getSuit() const
{
    return this->suit;
}

int Card::getNumber() const
{
    return this->number;
}

int Card::getValue() const
{
    if (this->number >= 10 && this->number <= 13)
        return 10;
    else if (this->number == 1)
        return 11;
    else
        return this->number;
}

bool Card::isAce() const
{
    return (this->number == ACE);
}

char Card::toChar() const
{
    return (char) ((this->card - 1) + START_CHAR);
}

// void Card::setChar(char ch)
// {
//     this->card = ch - START_CHAR + 1;
// }

// int Card::getCardNum()
// {
//     return card;
// }

void Card::setCard(int card)
{
    this->card = card;
    this->setData(card);
}

void Card::setData(int num)
{
    assert(num > 0);
    assert(num <= JOKER);
    if (this->card == JOKER)
    {
        this->suit = JOKER;
        this->number = JOKER;
    }
    else
    {
        this->suit = (card - 1) / 13;
        this->number = card % 13;
        if (this->number == 0)
            this->number = 13;
    }
}
